//通知公告
function onHjqcSuoActionRenderer(e) {
    var record = e.value;
    if (record != null) {
        var arr = record.split("@");
        var announce = arr[0];
        var isowner = arr[1];
    }
    var s = "";
    s += '&nbsp;<a class="mini-button mini-button-info"  onclick="look()"  >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
    if (record == null || announce == 2) {
        s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="editNoticeInfo()"  >&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>&nbsp';
        s += '&nbsp;<a class="mini-button mini-button-warning"  onclick="announce()"  >&nbsp;&nbsp;发布&nbsp;&nbsp;</a>&nbsp';
        s += '&nbsp;<a class="mini-button mini-button-danger"  onclick="delNocticeInfo()"  >&nbsp;&nbsp;删除&nbsp;&nbsp;</a>&nbsp';
    } else if (announce == "1" && isowner == "1") {
        s += '&nbsp;<a class="mini-button mini-button-warning"  onclick="withdraw()"  >&nbsp;&nbsp;取消发布&nbsp;&nbsp;</a>&nbsp';
    }
    s += '&nbsp;<a class="mini-button mini-button-success"  onclick="downloadFilesZip(21)"  >&nbsp;&nbsp;下载&nbsp;&nbsp;</a>&nbsp';
    return s;
}

//新增
function addNoticeInfo() {
    var data = {stat: 1};
    if (data) {
        showNoticeInfoWindow(data);
    }
}

//修改
function editNoticeInfo() {
    var row = grid.getSelected();
    if (row) {
        $.ajax({
            url: encodeURI("/azbj/tzgggl/noticeInfoManage/identical/" + row.createUser),
            cache: false,
            success: function (result) {
                if (result.code == 1) {
                    showNoticeInfoEditWindow(row);
                } else {
                    mini.alert("非本人发布的内容无法进行编辑");
                }

            }
        });
    } else {
        mini.alert("请至少选中一条记录");
    }
}

//删除
function delNocticeInfo() {
    var row = grid.getSelected();
    if (row) {
        $.ajax({
            url: encodeURI("/azbj/tzgggl/noticeInfoManage/identical/" + row.createUser),
            cache: false,
            success: function (result) {
                if (result.code == 1) {
                    commonRemove("/azbj/tzgggl/noticeInfoManage/delete/" + row.id, row, {_method: "delete"}, callback);

                    function callback() {
                        grid.reload();
                    }
                } else {
                    mini.alert("非本人发布的内容无法进行删除");
                }

            }
        });
    } else {
        mini.alert("请至少选中一条记录");
    }
}

//发布
function announce() {
    var row = grid.getSelected();
    if (row) {
        $.ajax({

            url: encodeURI("/azbj/tzgggl/noticeInfoManage/identical/" + row.createUser),
            cache: false,
            success: function (result) {
                if (result.code == 1) {
                    announceNoticeInfo(row);
                } else {
                    mini.alert("非本人发布的内容无法进行发布");
                }
                grid.reload();
            }
        });
    } else {
        mini.alert("请至少选中一条记录");
    }
}

//修改发布状态
function announceNoticeInfo(row) {
    if (row) {
        $.ajax({
            url: encodeURI("/azbj/tzgggl/noticeInfoManage/announce/" + row.id),
            cache: false,
            success: function (result) {
                if (result.code == 1) {
                    mini.alert("发布成功");
                } else {
                    mini.alert("发布失败");
                }
                grid.reload();
            }
        });
    } else {
        mini.alert("请至少选中一条记录");
    }
}

//撤回
function withdraw() {
    var row = grid.getSelected();
    if (row) {
        $.ajax({

            url: encodeURI("/azbj/tzgggl/noticeInfoManage/identical/" + row.createUser),
            cache: false,
            success: function (result) {
                if (result.code == 1) {
                    withdrawNoticeInfo(row);
                } else {
                    mini.alert("非本人发布的内容无法进行发布");
                }
                grid.reload();
            }
        });
    } else {
        mini.alert("请至少选中一条记录");
    }
}

//修改发布状态
function withdrawNoticeInfo(row) {
    if (row) {
        $.ajax({
            url: encodeURI("/azbj/tzgggl/noticeInfoManage/withdraw/" + row.id),
            cache: false,
            success: function (result) {
                if (result.code == 1) {
                    mini.alert("撤回成功");
                } else {
                    mini.alert("撤回失败");
                }
                grid.reload();
            }
        });
    } else {
        mini.alert("请至少选中一条记录");
    }
}

//查看
function look() {
    var row = grid.getSelected();
    if (row) {
        showNoticeInfo(row);
    } else {
        mini.alert("请至少选择一条数据！");
    }
}

//新增跳转页面
function showNoticeInfoWindow(row) {
    commonEdit("/azbj/tzgggl/noticeInfoManage/add", "通知公告信息管理", row, "55%", "65%", true, false, true, callback);

    function callback() {
        grid.reload();
    }
}

//修改跳转页面
function showNoticeInfoEditWindow(row) {
    commonEdit("/azbj/tzgggl/noticeInfoManage/edit", "通知公告信息管理", row, "55%", "65%", true, false, true, callback);

    function callback() {
        grid.reload();
    }
}

//查看跳转页面
function showNoticeInfo(row) {
    commonEdit("/azbj/tzgggl/noticeInfoManage/lookUp", "通知公告信息管理", row, "55%", "55%", true, false, true, callback);

    function callback() {
        grid.reload();
    }
}

//下载
function downloadFilesZip() {
    var row = grid.getSelected();
    if (row) {
        $.ajax({
            url: encodeURI("/azbj/tzgggl/noticeInfoManage/ifFileExist?id=" + row.id),
            cache: false,
            success: function (result) {
                if (result.code == 1) {
                    top.location.href = encodeURI("/azbj/tzgggl/noticeInfoManage/downloadFilesZip/" + row.id);
                } else {
                    mini.alert("没有可下载的文件");
                }
            }
        });
    } else {
        mini.alert("请至少选中一条记录");
    }
}

//格式化日期函数
function onDateRenderer(e) {
    var date = new Date(e.value);
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
    var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
    var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
    var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
    var formatTime = Y + M + D + h + m + s;
    return formatTime;
}